package me.zk.practice1.hw;

import java.util.*;

public class HWBJ26 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        //4
        //roolling3 stone4 like1 a2
        int n = Integer.parseInt(scanner.nextLine());


        String s = scanner.nextLine();

        String[] strs = s.split(" ");

        Map<Integer,String> map = new TreeMap<>(Comparator.naturalOrder());

        for (String s1 : strs) {
            for (int i = s1.length()-1; i >=0 ; i--) {
                char c = s1.charAt(i);
                if (Character.isLetter(c)) {
                    int begin = i+1;
                    int b = Integer.parseInt(s1.substring(begin));
                    while (b > 1000) {
                        begin +=1;
                        b = Integer.parseInt(s1.substring(begin));
                    }
                    map.put(b,s1.substring(0,begin));
                    break;
                }
            }

        }
        StringBuffer sb = new StringBuffer();
        Iterator<Integer> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            sb.append(map.get(iterator.next()));
            if (iterator.hasNext()) {
                sb.append(" ");
            }
        }
        System.out.println(sb.toString());
    }
}
